package cn.bdqn.mh.controller.api;

import cn.bdqn.mh.pojo.Ad;
import cn.bdqn.mh.pojo.Article;
import cn.bdqn.mh.response.Result;
import cn.bdqn.mh.response.ResultCode;
import cn.bdqn.mh.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/house")
@Configuration(value = "website")
@Api(value = "文章,新闻信息接口文档")
@Slf4j
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @GetMapping("/vshare")
    @ApiOperation(value = "查询微舍故事")
    public Object vShare(){
        List<Article> list=articleService.getVShare();
        Result result=null;
        if(list==null || list.size()==0){
            result = new Result(ResultCode.NO_DATAFOUND);
        }else {
            result = new Result(ResultCode.SUCCESS,list);
        }
        return result;
    }

    @GetMapping("/newsinfo")
    @ApiOperation(value = "查询新闻资讯")
    public Object newsInformation(){
        List<Article> list=articleService.getNewsInformation();
        Result result=null;
        if(list==null || list.size()==0){
            result = new Result(ResultCode.NO_DATAFOUND);
        }else {
            result = new Result(ResultCode.SUCCESS,list);
        }
        return result;
    }

    @GetMapping("/searchinfo")
    @ApiOperation(value = "查询右侧的推荐房源")
    public Object searchInformation(){
        List<Article> list=articleService.getSearchInformation();
        Result result=null;
        if(list==null || list.size()==0){
            result = new Result(ResultCode.NO_DATAFOUND);
        }else {
            result = new Result(ResultCode.SUCCESS,list);
        }
        return result;
    }
}
